<%--
  Created by IntelliJ IDEA.
  User: 殇
  Date: 2021/1/20
  Time: 11:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        库位添加
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="css/main.css" media="all">
    <script type="text/javascript" src="lib/loading/okLoading.js"></script>
    <style>
        .imgs{display: none;}
    </style>

</head>
<body>

<div class="x-body">
    <form class="layui-form layui-form-pane" action="" id="add">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">


            <div class="layui-tab-content" >
                <div class="layui-tab-item layui-show">
                    <input type="hidden" name="id" value="">
                    <div class="layui-form-item" style="margin-left: 15%;">
                        <div class="layui-input-inline" style="width: 40%;">
                            <label class="layui-form-label">
                                货物名称<span class='x-red'>*</span>
                            </label>
                            <div class="layui-input-block">
                                <input type="text" name="device_name" autocomplete="off" placeholder="请输入货物名称"
                                       class="layui-input" value="">
                            </div>
                        </div>
                        <div class="layui-input-inline" style="width: 40%;">
                            <label class="layui-form-label">
                                货物编码<span class='x-red'>*</span>
                            </label>
                            <div class="layui-input-block">
                                <input type="text" name="device_name" autocomplete="off" placeholder="请输入货位编码"
                                       class="layui-input" value="">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item" style="margin-left: 15%;">
                        <div class="layui-input-inline" style="width: 40%;">
                            <label class="layui-form-label">
                                长
                            </label>
                            <div class="layui-input-block">
                                <input type="text" name="device_name" autocomplete="off" placeholder="长"
                                       class="layui-input" value="">
                            </div>
                        </div>
                        <div class="layui-input-inline" style="width: 40%;">
                            <label class="layui-form-label">
                                宽
                            </label>
                            <div class="layui-input-block">
                                <input type="text" name="device_name" autocomplete="off" placeholder="请输入宽"
                                       class="layui-input" value="">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item" style="margin-left: 15%;">
                        <div class="layui-input-inline" style="width: 40%;">
                            <label class="layui-form-label">
                                高
                            </label>
                            <div class="layui-input-block">
                                <input type="text" name="device_name" autocomplete="off" placeholder="请输入高"
                                       class="layui-input" value="">
                            </div>
                        </div>
                        <div class="layui-input-inline" style="width: 40%;">
                            <label class="layui-form-label">
                                货位限重（kg）
                            </label>
                            <div class="layui-input-block">
                                <input type="text" name="device_name" autocomplete="off" placeholder="请输入货物限重"
                                       class="layui-input" value="">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item" style="margin-left: 15%;">
                        <div class="layui-input-inline" style="width: 40%;">
                            <label class="layui-form-label">
                                货位类型<span class='x-red'>*</span>
                            </label>
                            <div class="layui-input-block">
                                <select name="modules" lay-verify="required" lay-search="">
                                    <option value="">直接选择或搜索选择</option>
                                    <option value="1">layer</option>
                                    <option value="2">form</option>
                                    <option value="3">layim</option>
                                    <option value="4">element</option>
                                    <option value="5">laytpl</option>
                                    <option value="6">upload</option>
                                    <option value="7">laydate</option>
                                    <option value="8">laypage</option>
                                    <option value="9">flow</option>
                                    <option value="10">util</option>
                                    <option value="11">code</option>
                                    <option value="12">tree</option>
                                    <option value="13">layedit</option>
                                    <option value="14">nav</option>
                                    <option value="15">tab</option>
                                    <option value="16">table</option>
                                    <option value="17">select</option>
                                    <option value="18">checkbox</option>
                                    <option value="19">switch</option>
                                    <option value="20">radio</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-input-inline" style="width: 40%;">
                            <label class="layui-form-label">
                                货位状态<span class='x-red'>*</span>
                            </label>
                            <div class="layui-input-block">
                                <input type="radio" name="status" value="1" title="启用" checked="checked">
                                <div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon layui-anim-scaleSpring"></i>
                                    <div>启用</div>
                                </div>
                                <input type="radio" name="status" value="0" title="禁用" checked="checked">
                                <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
                                    <div>禁用</div>
                                </div>
                            </div>
                        </div>
                    </div>









                    <center>
                        <div class="layui-form-item">
                            <button class="layui-btn layui-btn-lg" type="button" lay-filter="add" lay-submit="">
                                保存
                            </button>

                            <button  class="layui-btn layui-btn-lg"type="button" lay-filter="clear" lay-submit="">
                                关闭
                            </button>

                        </div>
                        <!--</form>-->
                        <div style="height:100px;"></div>
                </div>
                </center>


            </div>

        </div>
    </form>
</div>
<script src="lib/layui/layui.js" charset="utf-8"></script>
<script src="js/x-layui.js" charset="utf-8"></script>
<script src="js/jquery.min.js" charset="utf-8"></script>

<script>
    $(function () {
        var username="xiyuan";
        //var username="惜缘";
        $("input[name='uasername']").val(username);
    })
</script>
<script>
    layui.use(['laydate','element','layer','form'], function(){
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        form = layui.form();
        laydate = layui.laydate;//日期插件
        okLoading.close($);
        form.render();



        //监听提交
        form.on('submit(add)', function(data){

            var uasername=$("input[name='uasername']").val();
            var device_name=$("input[name='device_name']").val();

            var community_id=$('#community_id option:selected') .val();//所属栏目ID
            if(community_id==""){
                layer.msg('所属小区不能为空',{icon:5,time:2000});return false;
            }
            if(uasername==""){
                layer.msg('报修人员不能为空',{icon:5,time:2000});return false;
            }
            if(device_name==""){
                layer.msg('设备名称不能为空',{icon:5,time:2000});return false;
            }
            var data=data.field;
            $.ajax({
                type:"post",
                url:"xxx",
                data:data,
                dataType:"json",
                success:function(data){
                    if(data.status==1)
                    {
                        layer.msg(data.info, {icon: 6,time:2000},function () {
                            window.parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                        return false;

                    }
                    else{
                        layer.msg(data.info,{icon:5,time:2000});return false;
                    }
                }

            });

        });


        //监听提交
        form.on('submit(clear)', function(data){
            var index=parent.layer.getFrameIndex(window.name); //获取当前窗口的name
            parent.layer.close(index);//关闭窗口
        });
    })
</script>
<!--栏目缩略图上传-->
<script>
    function upload()
    {
        var formData = new FormData();
        formData.append('images', $('#previewImg')[0].files[0]);
        //console.log(formData);
        layer.msg('图片上传中', {icon: 16});
        $.ajax({
            type:"post",
            processData: false,
            contentType: false,
            url:"xxx",
            data:formData,
            success:function(data){
                if(data.status == 1){
                    console.log(data.image_name);
                    layer.closeAll('loading');
                    //layer.msg(data.info,{icon:1,time:1000});
                    $("#pimages").attr('src',data.image_name);
                    $("#avatar").val(data.image_name);
                    $(".imgs").show();
                    return false;
                }else{
                    layer.msg(data.info,{icon:2,time:1000});
                }
            }
        });
    }
</script>

</body>
</html>
